#include <bits/stdc++.h>

using namespace std;

int t;
int n;
int a[200005];
bool vis[1000005];
int cnt[1000005];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	freopen ("color.in", "r", stdin);
	freopen ("color.out", "w", stdout);
	cin >> t;
	while (t--){
		cin >> n;
		memset (cnt, 0, sizeof(cnt));
		bool flag;
		flag = true;
		int mx = 0;
		for (int i = 1; i <= n; i++){
			cin >> a[i];
			vis[a[i]] = true;
			if (vis[a[i]])
				falg = false;
			cnt[a[i]]++;
			mx = max (mx, a[i]);
		}
		if (flag){
			cout << 0 << '\n';
			continue;
		}
		long long ans;
		for (int i = 1; i <= mx; i++){
			if (cnt[i] > 2){
				ans += (cnt[i] / 2 * i);
			}
		}
		cout << ans << '\n';
	}
	return 0;
}
